import requests,json

token_data = {
	"username": "admin",
	"password": "P1AmyxcTf8LBdcYFvbMwbg=="
}
# 获取token
response = requests.post('http://127.0.0.1:8000/adminapi/signin', data=token_data)
res = response.json()
token = res['token']

form_header = {"Authorization": "{}".format(token)}

#构建data
form_data = {
	"action": "compute"
}

#关闭多余连接
s = requests.session()
s.keep_alive = False

#登陆水电平台
login_data = {
	"username": "liandun",
	"password": "123456"
}

login = requests.post('http://www.ambcharge.com/pre/openapi/login', data=login_data)
login_index = login.json()
login_token = "Bearer {}".format(login_index['data'])

# response = requests.post('http://127.0.0.1:8000/guestapi/dispatcher', data=json.dumps(form_data), headers=form_header)
# print(response.json())